package io.renren.modules.generator.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.renren.modules.generator.entity.EnterpriseSafeMonitorEntity;
import io.renren.modules.generator.service.EnterpriseSafeMonitorService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 企业安全监控
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-09-22 15:49:20
 */
@RestController
@RequestMapping("generator/enterprisesafemonitor")
@Api("企业安全监控接口")
public class EnterpriseSafeMonitorController {
    @Autowired
    private EnterpriseSafeMonitorService enterpriseSafeMonitorService;

    /**
     * 列表
     */
    @RequestMapping("/all/list")
    @ApiOperation("根据企业id获取所有安全监控")
    public R list(@RequestBody EnterpriseSafeMonitorEntity enterpriseSafeMonitorEntity){
        List<EnterpriseSafeMonitorEntity> enterpriseSafeMonitorEntityList = enterpriseSafeMonitorService.selectList(enterpriseSafeMonitorEntity);

        return R.ok().put("data", enterpriseSafeMonitorEntityList);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation("分页列表")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = enterpriseSafeMonitorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ApiOperation("根据id获取实体")
    public R info(@PathVariable("id") Integer id){
		EnterpriseSafeMonitorEntity enterpriseSafeMonitor = enterpriseSafeMonitorService.getById(id);

        return R.ok().put("enterpriseSafeMonitor", enterpriseSafeMonitor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ApiOperation("保存")
    public R save(@RequestBody EnterpriseSafeMonitorEntity enterpriseSafeMonitor){
		enterpriseSafeMonitorService.save(enterpriseSafeMonitor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ApiOperation("更新")
    public R update(@RequestBody EnterpriseSafeMonitorEntity enterpriseSafeMonitor){
		enterpriseSafeMonitorService.updateById(enterpriseSafeMonitor);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ApiOperation("删除")
    public R delete(@RequestBody Integer[] ids){
		enterpriseSafeMonitorService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
